#! /bin/bash
echo "开始配置pip镜像..."
mkdir ~/.pip
echo "[global]
index-url = http://mirrors.blockelite.cn:15019/pip/pypi/+simple/
format = columns
trusted-host = mirrors.blockelite.cn" > ~/.pip/pip.conf
echo "pip镜像已配置：~/.pip/pip.conf"

echo "开始配置conda镜像..."
echo "channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud" > ~/.condarc
echo "conda镜像已配置：~/.condarc"

# 准备YOLOv8运行环境（此处卸载两遍）
pip uninstall ultralytics
pip uninstall ultralytics

# 安装requirements.txt里面的依赖包
pip install -r requirements.txt

pip install timm==0.9.8 thop efficientnet_pytorch==0.7.1 einops grad-cam==1.4.8 dill==0.3.6 albumentations==1.3.1 pytorch_wavelets==1.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install opencv-python install "opencv-python-headless<4.3"

# 安装dyhead需要的包（2080ti安装报错）
#pip install -U openmim
#mim install mmengine -i https://pypi.tuna.tsinghua.edu.cn/simple
#mim install "mmcv>=2.0.0" -i https://pypi.tuna.tsinghua.edu.cn/simple